BPROF

Section: User Commands (1)
Updated: Version 1.1 13 July 1994
Index Return to Main Contents
 

NAME

bprof - profile per source line  

SYNOPSIS

bprof [options] [executable [bmon.out ... ] ]  

DESCRIPTION

bprof makes an execution profile per source line of your program. In other words, it gives you the time spent in each line of your program. This allows you to know precisely on what part of the program to spend your efforts at speeding it up.

To get such a profile, compile your program with -g and link it with -pg and the library libbmon.a. Make sure that the bmon library is linked immediately after your .o files, before any system libraries. Example:

gcc -g -c foo.c
gcc -g -c bar.c
gcc -pg -o fubar foo.o bar.o -lbmon -lm

You can specify optimization flags. This will give you a better estimate of the program behaviour when it is optimized, but it can make the data hard to interpret as the relation between source and object code can be obscure.

Running the program should produce a file bmon.out in the current directory (that is the current directory of the program at the moment it exits). Now run bprof on your executable. This should produce files foo.c.bprof and bar.c.bprof which are the same as the corresponding source files, but have the time spent in each line prepended to that line. A '-' in the output indicates a line where no measurable time was spent, while a '.' indicates a line that is not executable at all.

Time spent is measured in clock ticks, so in 1/100 of a second. As timing statistics are taken stochastically by recording the instruction each clock tick, these numbers are not exact and can vary from one run to another.

The first non-option argument given will be taken as the name of the executable (default: a.out). Any further arguments are interpreted as the names of bmon.out files (default: bmon.out). If you specify more such files bprof takes the sum of the timings of these files.  

OPTIONS

-d directory
also use any source files in directory to make profiles. You can use multiple -d flags for multiple directories. The current directory is always used.

Note that in any case source files will only be looked for by the full path name they had at the moment of compilation. If you have moved them around since compilation, you need to recompile, move them back or create a symlink somewhere.

-s suffix
use suffix instead of .bprof to add to the source file names to get the output file names.
 

ENVIRONMENT

BPROFDIR
If this variable is set, the program will write the bmon.out file in that directory instead of the current one.
 

FILES

bmon.out
contains timing data
 

SEE ALSO

gprof(1)  

BUGS

I do not know of a way to get the last instruction address of a source line without looking at the next line. This means that if you link two object files, the first of which has been compiled with -g while the second one hasn't, time of the second file will be attributed to the last line of the first file. You can avoid any problems by linking the libbmon.a library (which should have been compiled with -g) immediately after your -g compiled files and before any others.

Profiling will not be done while your program is blocking the VTALRM signal.  

AUTHOR

Bas de Bakker, who can be reached by email at bas@phys.uva.nl. The latest version of bprof should be available at sunsite.unc.edu in the directory /pub/Linux/devel.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
ENVIRONMENT
FILES
SEE ALSO
BUGS
AUTHOR

This document was created by man2html, using the manual pages.
Time: 13:45:21 GMT, November 05, 2024